/**
 * 
 */
package com.ltmt.es.validator;

import java.util.List;

import com.ltmt.es.pojo.PrimitivaCombination;
import com.ltmt.es.utils.castor.PrimitivaCastor;

/**
 * @author aruizred
 *
 */
public class PrimitivaValidator {
	
	private List<PrimitivaCombination> listHPComb;
	
	public void statsValidator (PrimitivaCombination pComb) {
		
		//List<PrimitivaCombination> listHPComb = null;//TODO
		int hits;
		Integer[] hitAccumulator = {0,0,0,0,0};
		
		for (PrimitivaCombination hPComb : listHPComb){
			hits = hitCounter(pComb, hPComb);
			switch (hits) {
    		case 3 : 
    			hitAccumulator[0]++;
    			break;
    		case 4 : 
    			hitAccumulator[1]++;
    			break;
    		case 5 : 
    			if (this.containsComplementary(pComb, hPComb))
    				hitAccumulator[3]++;
    			else
    				hitAccumulator[2]++;
    			break;
    		case 6 : 
    			hitAccumulator[4]++;
    			break;
			}
		}
		
		pComb.setHitStats(PrimitivaCastor.toStats(hitAccumulator, listHPComb.size()));
		
	}

	private int hitCounter (PrimitivaCombination pComb, PrimitivaCombination hPComb){
		
		int hits = 0;
		
		for (int i : pComb.getCombination()){
			if (hPComb.getCombination().contains(i)) hits++;
		}
		
		return hits;
		
	}
	
	private boolean containsComplementary 
		(PrimitivaCombination pComb, PrimitivaCombination hPComb){
		
		return (pComb.getCombination().contains(hPComb.getComplementary()));
		
	}

	public List<PrimitivaCombination> getListHPComb() {
		return listHPComb;
	}

	public void setListHPComb(List<PrimitivaCombination> listHPComb) {
		this.listHPComb = listHPComb;
	}

}
